diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-10-18 22:22:55 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-10-18 22:22:55 +0200 |
| commit | 4efed80a2f8dc238b420eadf97d56c3eccaadb76 (patch) | |
| tree | 7732a80745622c097a9e75dfb056603bceb10a23 /src/routes/projects/[projectId] | |
| parent | 0685e9ece66fbcb09c9457027cf7bb2107cc0171 (diff) | |
refactor: inject the database into every servicemain
Groceries, projects, references and routines become classes holding the
Drizzle handle, wired once in services/index.ts alongside categories. Tests
build their own instance on an in-memory database. Drops the unused
projects.loadAll and projects.rename.
Diffstat (limited to 'src/routes/projects/[projectId]')
| -rw-r--r-- | src/routes/projects/[projectId]/routine/[routineId]/+page.server.ts | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/routes/projects/[projectId]/routine/[routineId]/+page.server.ts b/src/routes/projects/[projectId]/routine/[routineId]/+page.server.ts index cb14e0d..4ace86f 100644 --- a/src/routes/projects/[projectId]/routine/[routineId]/+page.server.ts +++ b/src/routes/projects/[projectId]/routine/[routineId]/+page.server.ts @@ -1,6 +1,5 @@ import { error } from '@sveltejs/kit'; -import { getById } from '$lib/server/services/projects'; -import { loadCurrent, loadCompletions } from '$lib/server/services/routines'; +import { projectsService, routinesService } from '$lib/server/services'; import { archiveRoutineAction, completeRoutineAction, @@ -14,17 +13,17 @@ export const load: PageServerLoad = async ({ params }) => { const projectId = numericId(params.projectId); const routineId = numericId(params.routineId); - const project = await getById(projectId); + const project = await projectsService.getById(projectId); if (!project || project.archived) { throw error(404, 'Projet introuvable'); } - const routine = await loadCurrent(routineId); + const routine = await routinesService.loadCurrent(routineId); if (!routine || routine.projectId !== projectId) { throw error(404, 'Routine introuvable'); } - const completions = await loadCompletions(routineId); + const completions = await routinesService.loadCompletions(routineId); // Archived routines are frozen at their archive instant, not now. const at = routine.archivedAt ? Temporal.Instant.from(routine.archivedAt) |
